//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package xmpp.androidpush.util;

import java.util.Locale;
import org.jivesoftware.smack.XMPPConnection;

public class XmppHelper {
    public XmppHelper() {
    }

    public static int tryToParseInt(String value, int defVal) {
        int ret;
        try {
            ret = Integer.parseInt(value);
        } catch (NumberFormatException var4) {
            ret = defVal;
        }

        return ret;
    }

    public static String capitalizeString(String original) {
        return original.length() == 0?original:original.substring(0, 1).toUpperCase(Locale.CHINA) + original.substring(1);
    }

    public static boolean verifyUserAndPW(String jid, String password) {
        return jid != null && !jid.matches(" *") && password.length() >= 6;
    }

    public static String getUserAtHost(String user, XMPPConnection con) {
        return user.contains("@")?user:user + "@" + con.getServiceName();
    }

    public static String getUserAtHost(String user, String serverName) {
        return user.contains("@")?user:user + "@" + serverName;
    }

    public static String getServerName(XMPPConnection con) {
        return con.getServiceName();
    }

    public static String getUser(String user) {
        if(isEmpty(user)) {
            return user;
        } else {
            int pos = user.indexOf("@");
            return pos != -1?user.substring(0, pos):user;
        }
    }

    public static boolean isEmpty(String input) {
        if(input != null && !"".equals(input)) {
            for(int i = 0; i < input.length(); ++i) {
                char c = input.charAt(i);
                if(c != 32 && c != 9 && c != 13 && c != 10) {
                    return false;
                }
            }

            return true;
        } else {
            return true;
        }
    }
}
